package adv10;
import java.beans.XMLEncoder;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.util.*;
public class SaveProducts {

	public static void main(String[] args) {
		//一步保存成xml
		List<Product> list=new ArrayList<Product>();
		list.add(new Product("1001","旺旺雪米饼", "南京", "袋", 23, 19.9, false));
		list.add(new Product("1002","QQtang", "南京", "袋", 34, 1, false));
		list.add(new Product("1003","hongjiu", "dawei", "ping", 33, 29.9, true));
		
		try {
			XMLEncoder xe=new XMLEncoder(new FileOutputStream("products3.xml"));
			xe.writeObject(list);//保存成xml
			xe.close();
		} catch (Exception e) {
			// TODO 自动生成的 catch 块
			e.printStackTrace();
		}
	}

}
